package boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qjn.springboot_starter_hello.HelloService;

@RestController
@SpringBootApplication
public class Application {

	@Value("${book.author}")
	private String bookAuthor;
	@Value("${book.name}")
	private String bookName;
	
	@Autowired
	private AuthorSettings authorSettings;
	@Autowired
	private HelloService helloService;
	
	@RequestMapping("/")
	String index() {
		return "book name is: "+ bookName + " and book author is: " + bookAuthor;
	}
	
	@RequestMapping("/author")
	String author() {
		return "author name is: " + authorSettings.getName() + " and age is: " + authorSettings.getAge();
	}
	
	@RequestMapping("/hello")
	String hello() {
		return helloService.sayHello();
	}
	
	public static void main(String[] args) {
		SpringApplication app = new SpringApplication(Application.class);
		app.run(args);
	}
}
